package com.qupai.controller.admin;

import com.qupai.dto.AuctionDTO;
import com.qupai.entity.Auction;
import com.qupai.result.Result;
import com.qupai.service.IAuctionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * <p>
 * 拍卖表，存储拍卖活动信息 前端控制器
 * </p>
 *
 * @author bluefoxyu
 * @since 2024-07-30
 */
@RestController
@RequestMapping("/admin/auction")
@Tag(name = "志愿-拍卖会相关接口")
public class AuctionController {

    @Resource
    private IAuctionService auctionService;

    @Operation(description = "获取所有拍卖会信息")
    @GetMapping
    public Result<List<Auction>> getAllAuction(){
        return Result.success(auctionService.list());
    }

    @Operation(description = "修改拍卖会信息")
    @PutMapping("/update")
    public Result<Auction> update(@RequestBody AuctionDTO auctionDTO){
        return Result.success(auctionService.updateAuction(auctionDTO));
    }

    @Operation(description = "删除指定id的拍卖会")
    @DeleteMapping("/delete/{auctionId}")
    public Result<String> deleteById(@PathVariable Long auctionId){
        auctionService.removeById(auctionId);
        return Result.success("删除成功");
    }


}
